#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll sum=1,x;
ll f(ll a)
{
	ll cnt=0;
	ll k=sqrt(a);
	for(int i=k-1;i>=1;i--)
		if(a%i==0)
			cnt+=2;
	if(k*k==a)
		cnt++;
	return cnt;
}
int main()
{
	int N;
	cin>>N;
	while(N--)
	{
		cin>>x;
		sum*=x;
	}
	ll t1,t2;
	for(ll i=x/2;i>=1;i--)
	{
		if(sum%i==0)
		{
			t1=f(i);
			t2=f(sum/i);
			if(abs(t1-t2)==1)
			{
				if(t1>t2)
				{
					cout<<i<<" "<<t1<<endl; 
					cout<<sum/i<<" "<<t2; 
				}
				else
				{
					cout<<sum/i<<" "<<t2<<endl; 
					cout<<i<<" "<<t1; 
				}
				break;
			}
		}
	}
    return 0;
}
